package com.xfusion.chatglm.data.infrastructure.repository;

import com.xfusion.chatglm.data.domain.auth.repository.IAuthRepository;
import com.xfusion.chatglm.data.infrastructure.redis.IRedisService;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

/**
 * 认证仓储服务
 */
@Repository
public class AuthRepository implements IAuthRepository {
    private static final String key = "weixin_code";
    @Resource
    private IRedisService redisService;
    @Override
    public String getCodeUserOpenId(String code) {
        return redisService.getValue(key+"_"+code);
    }

    @Override
    public void removeCodeByOpenId(String code, String openId) {
        redisService.remove(key+"_"+code);
        redisService.remove(key+"_"+openId);
    }
}
